package com.llxz.blog.cms.service.ipml;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.llxz.blog.cms.entity.Banner;
import com.llxz.blog.cms.mapper.BannerMapper;
import com.llxz.blog.cms.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BannerServiceImpl extends ServiceImpl<BannerMapper, Banner> implements BannerService {
    @Autowired
    BannerMapper bannerMapper;

    @Cacheable(value = "banners")
    @Override
    public List<Banner> selectBannerList(Long limit) {
        QueryWrapper<Banner> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("sort");
        wrapper.last("limit " + limit);
        List<Banner> banners = bannerMapper.selectList(wrapper);

        return banners;
    }
}
